{% import 'Dockerfile/docker.jinja2' as docker %}
{% import 'Dockerfile/provision.jinja2' as provision %}

{% macro mysql(role='') -%}
    && apt-get update \
	&& apt-get install -yq --no-install-recommends \
		libmariadb-java \
    && wget -q -O/tmp/liquibase.tar.gz "https://github.com/liquibase/liquibase/releases/download/liquibase-parent-${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}-bin.tar.gz" \
    && mkdir -p /opt/liquibase \
    && tar -xzf /tmp/liquibase.tar.gz -C /opt/liquibase \
    && rm -f /tmp/liquibase.tar.gz \
    && chmod +x /opt/liquibase/liquibase \
    && ln -s /opt/liquibase/liquibase /usr/local/bin/ \
    && chmod +x /opt/docker/bin/entrypoint.sh \
	&& apt-get clean \
	&& rm -r /var/lib/apt/lists/* \
    && mkdir /liquibase \
    && ln -sf /opt/docker/bin/entrypoint.sh /entrypoint \
    # cleanup
    && apt-get autoremove -y -f \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*
{%- endmacro %}

{% macro postgres(role='') -%}
    && apt-get update \
	&& apt-get install -yq --no-install-recommends \
		libpostgresql-jdbc-java \
    && wget -q -O/tmp/liquibase.tar.gz "https://github.com/liquibase/liquibase/releases/download/liquibase-parent-${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}-bin.tar.gz" \
    && mkdir -p /opt/liquibase \
    && tar -xzf /tmp/liquibase.tar.gz -C /opt/liquibase \
    && rm -f /tmp/liquibase.tar.gz \
    && chmod +x /opt/liquibase/liquibase \
    && ln -s /opt/liquibase/liquibase /usr/local/bin/ \
    && chmod +x /opt/docker/bin/entrypoint.sh \
	&& apt-get clean \
	&& rm -r /var/lib/apt/lists/* \
    && mkdir /liquibase \
    && ln -sf /opt/docker/bin/entrypoint.sh /entrypoint \
    # cleanup
    && apt-get autoremove -y -f \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*
{%- endmacro %}
